function [ output ] = Limiter( data, R, limits, thres, limitRange)
%%
% limitRange = 1 will allow to grow in specified interval and will limit
% outside
%%
        output = data;
        M = max(size(data));
        
        %Iki kurios dalies bus dedamas apribojimas
        limits = int16(M * limits);
        limits(limits == 0) = 1;
        
        %apribojimo dydis (ne daugiau nei kazkiek)
        
        
        if limitRange == 1,
            limiter = thres;
            allower = 999;
        else
            limiter = 999;
            allower = thres;
        end
        
        I = ones(size(data))*limiter;
        
        for i=1:R,
            range = limits(i, 1):limits(i, 2);
            if size(range,2) == 1,
                continue
            end
            
            if size(data,1) == R,
                I(i, range) = allower;
            else
                I(range, i) = allower;
            end
        end
        
        
        output(output > I) = thres;
end

